//
//  competitionView.m
//  MyLittleBrother
//
//  Created by speeda on 17/8/9.
//  Copyright © 2017年 speeda. All rights reserved.
//

#import "competitionView.h"
#import "CoverView.h"

@implementation CompetitionView

+ (instancetype)competitionViewFormXib {
    
    [CoverView showCoverView];
    
    CompetitionView *view = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil].firstObject;
    view.center = [UIApplication sharedApplication].keyWindow.center;
    view.backgroundColor = [UIColor whiteColor];
    view.alpha = 0.0;
    UIWindow *window = [UIApplication sharedApplication].windows.lastObject;
    [window addSubview:view];
    
    [UIView animateWithDuration:0.2 animations:^{
        view.alpha = 1.0;
    }];
    
    return view;
}



#pragma mark -- 取消
- (IBAction)cancelBtnAction:(id)sender {
    
    for (UIView *view in [UIApplication sharedApplication].keyWindow.subviews) {
        
        if ([view isKindOfClass:[CompetitionView class]]) {
            
            [view removeFromSuperview];
        }
        
        if ([view isKindOfClass:[CoverView class]]) {
            
            [view removeFromSuperview];
        }
        
    }
}


#pragma mark -- 去比武
- (IBAction)competitionBtnAction:(id)sender {
    
    if ([_delegate respondsToSelector:@selector(competitionViewWithcompetitionButton)]) {
        [_delegate competitionViewWithcompetitionButton];
    }
}

@end
